"""日历表"""
# w=y+[y/4]+[c/4]-2c+[26(m+1)/10]+d-1

def menology(year, month):
    """万年历"""
    years = year % 100
    cty = year // 100
    if month in (1, 2):
        cty = (year-1) // 100
        years = (year - 1) % 100
        week_index = (years - 1) + (years - 1) // 4 + cty // 4 - 2 * cty + (26 * (month + 13) / 10) + 7000
    else:
        week_index = years + years // 4 + cty // 4 - 2 * cty + (26 * (month + 1) / 10) + 7000
    week_index = int(week_index) % 7
    week = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa']
    months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
    if year % 4 == 0 and year % 100 != 0 or year % 400 == 0:
        months[1] += 1
    print(f'         {year}年{month}月')
    for mts in week:
        print(mts + '  ', end='', sep='')
    print()
    print("  " * 2 * week_index, end='', sep='')
    for day in range(months[month - 1]):
        print(' ', day + 1, '  ', end='', sep='') if day < 9 else print(day + 1, '  ', end='', sep='')
        week_index += 1
        if week_index == 7:
            print()
            week_index = 0
    print()

def my_sort(list1: list, list2: list, le=lambda x, y: x <= y):
    """排序"""
    list3 = []
    index1, index2 = 0, 0
    while index1 < len(list1) and index2 < len(list2):
        if le(list1[index1], list2[index2]):
            list3.append(list1[index1])
            index1 += 1
        else:
            list3.append(list2[index2])
            index2 += 1
    list3 += list1[index1:]
    list3 += list2[index2:]
    return list3

def my_sort2(list1:list, le=lambda x, y: x <= y):
    """归并排序"""
    if len(list1) <= 1:
        return list1
    mid = len(list1) // 2
    list2 = my_sort2(list1[:mid], le)
    list3 = my_sort2(list1[mid:], le)
    return my_sort(list2, list3, le)

n = [1,2312,321,5323,4342,62,221,13,1]
print(my_sort2(n))

menology(2005, 1)
menology(2005, 4)
menology(2004, 5)

